//
//  BaseNavController.swift
//  Sinaweibo
//
//  Created by 谌桃 on 15/12/3.
//  Copyright © 2015年 ryan.chen. All rights reserved.
//

import UIKit

class BaseNavController: UINavigationController {

    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
    }

    //重写导航控制器的push方法
    override func pushViewController(viewController: UIViewController, animated: Bool) {
        
        if childViewControllers.count != 0{
            
           //当执行push的时候 就隐藏底部bar
           viewController.hidesBottomBarWhenPushed = true
            
           //设置导航条的 返回按钮
            viewController.navigationItem.backBarButtonItem = UIBarButtonItem(title: "", style: .Plain, target: self, action: "back")
        }
        
        //一定要调用父类的方法
        super.pushViewController(viewController, animated: true)
        
    }
    
    
    @objc private func back(){
    
        dismissViewControllerAnimated(true, completion: nil)
    }
    
    
}
